<%--
  Created by IntelliJ IDEA.
  User: kuankuan
  Date: 2023/3/7
  Time: 9:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <script src="/js/jquery-1.12.4.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <style>
        body {
            background: none repeat scroll 0 0 #D8EDFC;
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>

<table width="600" align="center"  class="table table-striped table table-bordered">
    <caption>菜品管理</caption>
    <thead>
    <th>food_id</th>
    <th>type_id</th>
    <th>food_name</th>
    <th>food_price</th>
    <th>food_mprice</th>
    <th>food_image</th>
    <th>food_desc</th>
    <th width="200">操作</th>
    </thead>
    <tbody>
    <c:forEach var="food" items="${requestScope.pageBean1.datas}">
        <tr>
            <td>${food.food_id}</td>
            <td>${food.type_id}</td>
            <td>${food.food_name}</td>
            <td>${food.food_price}</td>
            <td>${food.food_mprice}</td>
            <td><img src="${food.food_image}" style="width: 60px; height: 60px"></td>
            <td>${food.food_desc}</td>
            <td>
                <a href="/food?action=update&food_id=${food.food_id}">更新</a>
                <a onclick="deleteUser('${food.food_name}', ${food.food_id})">删除</a>
            </td>
        </tr>
    </c:forEach>
    <tr>
        <td colspan="8" align="center"><a href="/food?action=add">新增</a></td>
    </tr>
    </tbody>
</table>
<script>
    function deleteUser(name, id){
        if(confirm('是否确认删除'+name+"?")) {
            open('/food?action=delete&food_id='+id,'_self')
        }
    }

    onload = function () {
        if('${sessionScope.delMsg}' !== ''){
            alert('${sessionScope.delMsg}')
            fetch("/food?action=delMsg");
        }
    }
</script>
</body>
</html>
